const theScript = document.createElement('script');
theScript.innerHTML =
`

window.onload = myClock;

function myClock() {
    //每隔2分钟秒执行一次
    window.setInterval("clockSort120()", 1000*60*2);
    //每隔10秒执行一次
    window.setInterval("clockSort10()", 1000*10);
}

//2分钟一次
function clockSort120() {
    console.warn("clockSort120=====>执行一次");
    //变更当前学习视频
    StartCurStudy();

}

//10秒1次
function clockSort10() {
    console.warn("clockSort10=====>执行一次");
    //去掉5分钟一次的屏蔽
    RemoveWarningHtml();
    //提交学习进度
    submitStudy();

}


function testfun() {
    console.warn("vince=====>testfun");
}
//改版代码

//追加单点跟踪
function showSingleTrack(title) {
    console.warn("vince=====>showSingleTrack");


}
//作弊提示
function CheatWarming(title) {

}


//提交学习
function submitStudy() {
    //进度
    var actualSchedule = GetCurSchedule();
    var viewschedule = 0;
    if ($("#hidViewSchedule").length > 0) {
        viewschedule = $("#hidViewSchedule").val();
    }
    var masterTypeStr = masterType;
    if (masterType != "Plan" && masterType != "PlanStudy" && masterType != "Position" && masterType != "PositionStudy") {
        masterTypeStr = "";
    }
    var arr = '{"OrgID":"' + orgID + '","UserID":"' + userID + '","KnowledgeID":"' + key + '","PackageID":"' + packageID + '","MasterID":"' + masterID + '","MasterType":"' + masterTypeStr + '","PageSize":' + pageSize + ',"StudyTime":-1,"studyChapterIDs":"' + stuChpIDs + '","Type":' + type + ',"IsOffLine":false,"DeviceId":"","IsEnd":false,"ReqType":0,"IsCare":true,"viewSchedule":' + parseFloat(viewschedule) + '}';

    console.warn("submitStudy===》vince");

    console.warn(arr);

    AjaxCallApiMethod({


        type: "POST",
        url: "study",
        data: arr,
        success: function (result) {
            console.warn("success===》vince" + result);


            if (result == "") {
                $('#divCheat').hide();
                //返回当前用户学习实体
                if (standardStudyHours > actualStudyHours) {
                    $("#divCompletedArea").hide();
                    if (fileType != "ScormCourse") {
                        $("#divStartArea").show();
                    }
                } else {
                    if (fileType != "ScormCourse") {
                        $("#divCompletedArea").show();
                    }
                    $("#divStartArea").hide();
                    isHere = 1;
                    if ($('#icon' + key)) {
                        $('#icon' + key).prop("class", "pic2");
                        iscurfinish = 1;
                    }
                }
                MinuteChange(actualSchedule);
            } else {
                if (result.indexOf('﹡') > -1) {
                    var arrResult = result.split('﹡');
                    if (arrResult.length > 0) {
                        result = arrResult[1];
                        if (result.length > 8) {
                            result = result.substring(0, 8) + "...";
                        }
                        result = "[" + result + "]";
                    }
                }
                //那么返回的是知识名称
                CheatWarming(result);
            }
        },
        error: function (xhr) {
            console.warn("error===》vince" + xhr);

            var msg = eval("(" + xhr.responseText + ")");

            console.warn("error===》vince===" + msg);


            var result = msg.error.message;
            if (result.indexOf('﹡') > -1) {
                var arrResult = result.split('﹡');
                if (arrResult.length > 0) {
                    result = arrResult[1];
                    if (result.length > 8) {
                        result = result.substring(0, 8) + "...";
                    }
                    result = "[" + result + "]";
                }
            }
            CheatWarming(result);

            console.warn("error===》result===" + result);

        }
    });
}


///立即开始当前的知识学习
function StartCurStudy() {
    var id = $("#hidKnowledgeID").val();
    var masterTypeStr = masterType;
    if (masterType != "Plan" && masterType != "PlanStudy" && masterType != "Position" && masterType != "PositionStudy") {
        masterTypeStr = "";
    }

    var arr = '{"orgID":"' + orgID + '","userID":"' + userID + '","knowledgeID":"' + key + '","packageID":"' + packageID + '","masterID":"' + masterID + '","masterType":"' + masterTypeStr + '"'  +'}';

    var arr2 = '{"orgID":"b303cd69-88ea-412f-9461-ceec0aa9f11d","userID":"058460cd-dca2-40c9-9857-c3c681d6f693","knowledgeID":"' + id + '","packageID":"ddec9d68-294d-46ac-b618-1e77e58c8911","masterID":"0555da4f-f68e-482f-bb61-d1e3d588b734","masterType":"Plan"}';


    console.warn("StartCurStudy===》arr===" + arr);

    console.warn("StartCurStudy===》arrRight===" + arr2);


    jQuery.ajax({
        type: "POST",
        contentType: "text/json",
        url: "/Services/StyService.svc/ChangeStudyKnowledge",
        data: arr,
        dataType: 'json',
        cache: false,
        success: function (result) {
            var url = window.location.href;
            if (url.indexOf("tmp=") < 0) {
                if (url.indexOf("?") > -1) {
                    window.location.search += "&tmp=" + Date.parse(new Date());
                } else {
                    window.location.search += "?tmp=" + Date.parse(new Date());
                }
            }
            else {
                var c = url.indexOf("tmp=");
                var v = url.substring(c + 4, c + 17);
                var v1 = v + 1;
                url = url.replace(v, v1);
                window.location.href = url;
            }
        }
    });

}


//改版代码

//测试，20学完
//可以考虑增加多个userId


`
;
document.body.appendChild(theScript);
